/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.SOP;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;
import merlion.crm.slcm.session.SLCSessionBeanLocal;
import merlion.crm.sopm.entity.PurchaseOrder;
import merlion.crm.sopm.session.SOPSessionBeanLocal;

/**
 *
 * @author Yuwei
 */
@ManagedBean(name = "spoManagerBean")
@SessionScoped
public class SearchPOManagerBean {
    
    @EJB
    private SLCSessionBeanLocal sLCSessionBean;
    @EJB
    private SOPSessionBeanLocal sOPSessionBean;
    private List<PurchaseOrder> pos;
    private SelectItem[] categoryOptions;
    private final static String[] categories;
    
    static{
        categories = new String[2];
        categories[0] = "WholeSale";
        categories[1] = "DirectSale";
    }
    /** Creates a new instance of SearchCustomerManagerBean */
    public SearchPOManagerBean() {
        pos = new ArrayList<PurchaseOrder>();
    }
    
     private SelectItem[] createFilterOptions(String[] data)  {  
        SelectItem[] options = new SelectItem[data.length + 1];  
  
        options[0] = new SelectItem("", "Select");  
        for(int i = 0; i < data.length; i++) {  
            options[i + 1] = new SelectItem(data[i], data[i]);  
        }  
  
        return options;  
    }

    public SelectItem[] getCategoryOptions() {
	    categoryOptions = createFilterOptions(categories);
        return categoryOptions;
    }

    public void setCategoryOptions(SelectItem[] categoryOptions) {
        this.categoryOptions = categoryOptions;
    }

    public List<PurchaseOrder> getPos() {
	pos = sOPSessionBean.getAllPurchaseOrders();
        return pos;
    }

    public void setPos(List<PurchaseOrder> pos) {
        this.pos = pos;
    }

    public SLCSessionBeanLocal getsLCSessionBean() {
        return sLCSessionBean;
    }

    public void setsLCSessionBean(SLCSessionBeanLocal sLCSessionBean) {
        this.sLCSessionBean = sLCSessionBean;
    }

    public SOPSessionBeanLocal getsOPSessionBean() {
        return sOPSessionBean;
    }

    public void setsOPSessionBean(SOPSessionBeanLocal sOPSessionBean) {
        this.sOPSessionBean = sOPSessionBean;
    }
     
}
